package com.itheima01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JDBCDemo03 {
    public static void main(String[] args)throws Exception {
        int i = 0;
        // 注册驱动
        Class.forName("com.mysql.jdbc.Driver");

        // 获取连接
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db2", "root", "123");

        // 获取执行对象
        Statement stat = con.createStatement();

        // 执行sql语句，并返回结果
        String sql = "update product set price='25',stock='100' where id='6'";
        i = stat.executeUpdate(sql);

        // 处理结果\
        if (i != 0){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }

        // 释放资源
        stat.close();
        con.close();

    }
}
